import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
   {
    title: '证书名称',
    dataIndex: 'certificateName'
   },
   {
    title: '证书描述',
    dataIndex: 'certificateRemark'
   },
   {
    title: '证书地址',
    dataIndex: 'certificatePath'
   },
   {
    title: '创建时间',
    dataIndex: 'createTime'
   },
];

export const searchFormSchema: FormSchema[] = [
 {
    label: '证书名称',
    field: 'certificateName',
    component: 'Input'
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  {label: '', field: 'certificateId', component: 'Input', show: false},
   { label: '', field: 'isEdit', component: 'InputNumber', show: false },
  {
    label: '证书名称',
    field: 'certificateName',
    component: 'Input',
    rules: [{ required: true, message: "请输入证书名称" }],
    dynamicDisabled: ({ values }) => {
     if (values.isEdit != undefined && values.isEdit == true) {
       return true
     } else {
       return false
     }
    },
  },
  {
    label: '证书地址',
    field: 'certificatePath',
    component: 'Input',
    rules: [{ required: true, message: "请输入证书地址" }],
    dynamicDisabled: ({ values }) => {
     if (values.isEdit != undefined && values.isEdit == true) {
       return true
     } else {
       return false
     }
    },
  },
  {
    label: '证书描述',
    field: 'certificateRemark',
    component: 'Input',
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  }
];
